10 'This routine, in combination with associated BAT files, will subtract a directory search path from an existing path.
20 '
30 'In order to pass a parameter (in this case, the directory path to be added) into a BASIC program, the first executed BAT file, SUBPATH.BAT, places the
40 'parameter (the path to be deleted)into an environment section (see the DOS SET command) that is accessible through BASIC.
50 '
60 'This program then creates yet another BAT file that executes the new path command and cleans up all of the intermediate files and environments.
70 OPEN "subpath.dat" FOR INPUT AS 1 'Output from PATH command, Created by SUBPATH.BAT
80 LINE INPUT #1, A$ 'Read it into a$
90 'Change it all to upper case
100 PLEN=LEN(A$)
110 FOR I = 1 TO PLEN
120 AV = ASC(MID$(A$,I,1))
130 IF AV > 96 AND AV <123 THEN AV=AV-32: MID$(A$,I,1)=CHR$(AV)
140 NEXT I
150 PARM$=ENVIRON$("PAT")
160 OPEN "subpat.bat" FOR OUTPUT AS 2 'To create a new BAT file
170 PARMLEN=LEN(PARM$)
180 IF PARMLEN=0 THEN GOTO 420
190 'Change input parm to all upper case
200 FOR I = 1 TO PARMLEN
210 PV = ASC(MID$(PARM$,I,1))
220 IF PV > 96 AND PV <123 THEN PV=PV-32: MID$(PARM$,I,1)=CHR$(PV)
230 NEXT I
240 IF A$="NO PATH" THEN A$="":GOTO 380 'PATH command output is "No Path" if there was no previous path. This sets it to blank.
250 PATHLEN=LEN(A$)
260 FOR I=1 TO PATHLEN-PARMLEN+1
270 IF MID$(A$,I,PARMLEN)=PARM$ THEN IPOS=I: GOTO 440 'Found the string
280 NEXT I
290 GOTO 390 'Not found
300 REM: Create a batch file for doing the new SET PATH= command
310 PRINT #2, "ECHO Setting "+NEWPATH$ 'Display the new path
320 PRINT #2, "SET "+NEWPATH$ 'Issues SET PATH= command, with desired path deleted.
330 PRINT #2, "SUBPATH" 'Go back to DELETE SUBPAT.BAT
340 CLOSE #1
350 KILL "subpath.dat" 'Delete the intermediate file
360 CLOSE
370 SYSTEM
380 PRINT "The current PATH is empty. ";: GOTO 430
390 PRINT "The path element requested for deletion does not exist."
400 PRINT " Run the PATH command without parameters to see the current PATH."
410 GOTO 430
420 PRINT "No pathname entered. ";:GOTO 430
430 COLOR 14,0: PRINT "No action has been taken.": COLOR 7,0: GOTO 330